; Music of Task Force (1989) (Players) (Richard Cooke)
; Ripped by Megachur the 05/03/2009

; Need System Vectors

	write "TASKFORC.BIN"

music_date_rip	equ &0539
music_adr	equ &a300
first_theme	equ 0
last_theme	equ 0	; 0 -> 0

	read "music_header_v1_0.asm"

	jr la329	; play_music
.la308 equ $ + 6
.la306 equ $ + 4
.la304 equ $ + 2
.la302
	dw l1830,l1843,l1842,l1842
.la30a
	db #06
.la311 equ $ + 6
.la30e equ $ + 3
.la30d equ $ + 2
.la30c equ $ + 1
.la30b
	db #06,#00,#00,#00,#00,#00,#00,#00
	db #81
	dw la34e
.la31a equ $ + 4
.la317 equ $ + 1
	db #00,#04,#05,#05,#00,#00,#00,#0f
.la323 equ $ + 5
.la320 equ $ + 2
.la31e
	db #00,#00,#02,#05,#00,#00,#00,#00
.la327 equ $ + 1
	db #0d,#00,#00
;
.real_init_music
.la329
;
	ld hl,la30e
	ld b,#81
	ld de,la34e
	call #bce0
.la334
	ld a,(la30c)
	cp #12
	call z,la356
	ld a,#4c
	call #bb1e
	jp nz,#a429
	ld a,#1a
.la348 equ $ + 2
	call #bb1e
.la34b equ $ + 2
.la349
	jp nz,#a426
	jr la334
;
.play_music_counter
.la34e
;
	ld a,(la30c)
	inc a
	ld (la30c),a
	ret
;
.real_play_music
.la356
;
	xor a
	ld (la30c),a
	ld a,(la30a)
	cp #00
	jr z,la36d
	sub #06
	ld (la30a),a
	xor a
	ld (la30d),a
	jp la3b3
.la36d
	ld hl,(la306)
	ld a,(hl)
	cp #ff
	jp nz,la395
	ld hl,(la302)
	inc hl
	ld a,(hl)
	cp #ff
	jr nz,la382
	ld hl,l1830
.la382
	ld (la302),hl
	ld c,(hl)
	ld hl,l184a
	sla c
	ld b,#00
	add hl,bc
	ld e,(hl)
	inc hl
	ld d,(hl)
	ld (la306),de
.la395
	ld hl,(la306)
	ld e,(hl)
	inc hl
	ld d,(hl)
	inc hl
	ld a,(hl)
	sla a
	inc hl
	ld (la306),hl
	ld (la31e),a
	ld (la30a),a
	ex de,hl
	add hl,hl
	ld (la31a),hl
	ld a,#01
	ld (la30d),a
.la3b3
	ld a,(la30b)
	cp #00
	jr z,la3c2
	sub #06
	ld (la30b),a
	jp la411
.la3c2
	ld hl,(la308)
	ld a,(hl)
	cp #ff
	jp nz,la3ea
	ld hl,(la304)
	inc hl
	ld a,(hl)
	cp #ff
	jr nz,la3d7
	ld hl,l1843
.la3d7
	ld (la304),hl
	ld c,(hl)
	ld hl,l184a
	sla c
	ld b,#00
	add hl,bc
	ld e,(hl)
	inc hl
	ld d,(hl)
	ld (la308),de
.la3ea
	ld hl,(la308)
	ld e,(hl)
	inc hl
	ld d,(hl)
	inc hl
	ld a,(hl)
	sla a
	inc hl
	ld (la308),hl
	ld (la327),a
	ld (la30b),a
	ex de,hl
	add hl,hl
	ld (la323),hl
	ld hl,la320
	call #bcaa
	ld a,(la30b)
	sub #06
	ld (la30b),a
.la411
	ld a,(la30d)
	cp #00
	ret z
	ld hl,la317
	call #bcaa
	ld a,(la30a)
	sub #06
	ld (la30a),a
	ret
	
;&1830
.l1830
	db #02,#02,#06,#06,#07,#07,#05,#05
	db #03,#03,#08,#08,#09,#09,#0a,#0a
	db #03,#09
.l1842
	db #ff
.l1843
	db #01,#01,#06,#06,#07,#07,#05
.l184a
	db #05,#ff
	dw l1860,l1879,l1892,#0000
	dw l18f5,l18c3,l18dc,l190e
	dw l193f,l1964
.l1860
	db #ef,#00,#06,#ef,#00,#06,#77,#00
	db #06,#ef,#00,#06,#77,#00,#06,#ef
	db #00,#06,#86,#00,#06,#77,#00,#06
.l1879 equ $ + 1
	db #ff,#de,#01,#06,#de,#01,#06,#77
	db #00,#06,#de,#01,#06,#77,#00,#06
	db #de,#01,#06,#86,#00,#06,#77,#00
.l1892 equ $ + 2
	db #06,#ff,#1e,#00,#48,#16,#00,#0c
	db #1e,#00,#0c,#14,#00,#30,#19,#00
	db #30,#16,#00,#48,#19,#00,#0c,#1b
	db #00,#0c,#32,#00,#0c,#19,#00,#0c
	db #32,#00,#0c,#19,#00,#0c,#35,#00
	db #0c,#1b,#00,#0c,#35,#00,#0c,#1b
.l18c3 equ $ + 3
	db #00,#0c,#ff,#2d,#01,#06,#2d,#01
	db #06,#96,#00,#06,#2d,#01,#06,#96
	db #00,#06,#2d,#01,#06,#9f,#00,#06
.l18dc equ $ + 4
	db #96,#00,#06,#ff,#0c,#01,#06,#0c
	db #01,#06,#86,#00,#06,#0c,#01,#06
	db #86,#00,#06,#0c,#01,#06,#96,#00
.l18f5 equ $ + 5
	db #06,#86,#00,#06,#ff,#66,#01,#06
	db #66,#01,#06,#b3,#00,#06,#66,#01
	db #06,#b3,#00,#06,#66,#01,#06,#c9
.l190e equ $ + 6
	db #00,#06,#b3,#00,#06,#ff,#14,#00
	db #48,#11,#00,#0c,#0f,#00,#0c,#0d
	db #00,#18,#0d,#00,#18,#0f,#00,#18
	db #11,#00,#0c,#0f,#00,#48,#11,#00
	db #0c,#13,#00,#0c,#14,#00,#0c,#16
	db #00,#18,#14,#00,#18,#19,#00,#18
.l193f equ $ + 7
	db #16,#00,#0c,#1e,#00,#0c,#ff,#0f
	db #00,#60,#0d,#00,#60,#0f,#00,#24
	db #11,#00,#24,#13,#00,#18,#16,#00
	db #60,#0d,#00,#60,#0a,#00,#60,#09
	db #00,#24,#08,#00,#24,#07,#00,#18
.l1964 equ $ + 4
	db #0b,#00,#60,#ff,#3c,#00,#54,#32
	db #00,#06,#3c,#00,#06,#4b,#00,#54
	db #43,#00,#06,#3c,#00,#06,#43,#00
	db #54,#3c,#00,#06,#43,#00,#06,#59
	db #00,#60,#3c,#00,#54,#32,#00,#06
	db #2d,#00,#06,#32,#00,#54,#2d,#00
	db #06,#26,#00,#06,#2d,#00,#54,#43
	db #00,#06,#32,#00,#06,#3c,#00,#60
	db #ff
;
; initialized in basic
;
;;70 ENT 1,2,10,1,1,8,1,2,4,1:ENV 1,1,10,1,4,-1,1
;;80 ENV 5,2,-1,5,2,-1,20,11,-1,40:ENT -5,1,-1,1,1,-1,2,1,1,2,1,1,1  
;;90 ENV 2,15,-1,3:ENT 2,5,-10,2:ENV 3,8,-1,6,4,-1,8:ENV 4,15,-1,2
;
.init_music ; added by Megachur
;
	ld hl,ent1
	ld a,1
	call #bcbf
	ld hl,env1
	ld a,1
	call #bcbc
	ld hl,env5
	ld a,5
	call #bcbc
	ld hl,ent5
	ld a,-5
	call #bcbf
	ld hl,env2
	ld a,6
	call #bcbc
	ld hl,ent2
	ld a,2
	call #bcbf
	ld hl,env3
	ld a,3
	call #bcbc
	ld hl,env4
	ld a,4
	call #bcbc

	ld hl,la30e
	ld b,#81
	ld de,play_music
	jp #bce0
;
.play_music	; added by Megachur
;
	ld a,(la30c)
	inc a
	ld (la30c),a
;	ld a,(la30c)
	cp #12
	call z,la356
	ret

; ENT 1,2,10,1,1,8,1,2,4,1
ent1
	db 3
	db 2,10,1,1,8,1,2,4,1
; ENV 1,1,10,1,4,-1,1
env1
	db 2
	db 1,10,1,4,-1,1
; ENV 5,2,-1,5,2,-1,20,11,-1,40
env5
	db 3
	db 2,-1,5,2,-1,20,11,-1,40
; ENT -5,1,-1,1,1,-1,2,1,1,2,1,1,1
ent5
	db &84
	db 1,-1,1,1,-1,2,1,1,2,1,1,1
; ENV 2,15,-1,3
env2
	db 1
	db 15,-1,3
; ENT 2,5,-10,2
ent2
	db 1
	db 5,-10,2
; ENV 3,8,-1,6,4,-1,8
env3
	db 2
	db 8,-1,6,4,-1,8
; ENV 4,15,-1,2
env4
	db 1
	db 15,-1,2
;
.game_name
	db "Task Force",0
.game_year
	db "1989",0
.game_publisher
	db "Players",0
.music_author
	db "Richard Cooke",0
.music_comment
	db "",0

	read "music_end_v1_0.asm"
